<?php
/*
 * @Date: 2021-01-28 22:46:28
 * @名称: 漫画 · 操作控制器 · 修改漫画章节
 * @版本: 0.01
 * @作者: 初雪桜
 * @邮箱: 202184199@qq.com
 * @最后编辑: 初雪桜
 * @LastEditTime: 2021-01-28 22:55:15
 * @FilePath: /Site/app/useradmin/controller/Comics/Operation/Method/ComicsEditProject.php
 */

namespace app\useradmin\controller\Comics\Operation;

use app\BaseController;
use think\facade\Db;
use think\facade\View;

class ComicsEditProject extends BaseController
{
    /**
     * @方法名: 修改分卷内容
     * @作者: 初雪桜
     * @信息: 修改分卷内容
     * @param {String} $bookId 书籍id
     * @param {String} $projectId 分卷id
     * @param {String} $time 时间戳
     * @param {String} $hashHmac_bookId sha512后的书籍id
     * @param {String} $hashHmac_projectId sha512后的分卷id
     * @return {html}
     */
    public function EditProject($bookId, $projectId, $time, $hashHmac_bookId, $hashHmac_projectId)
    {
        $project_info =  Db::table('book_info_project')
            ->where([
                "_id" => $bookId,
                "chapter_id" => $projectId,
            ])
            ->field([
                "project_title",
                "order",
                "database_table_name",
            ])
            ->select();
        $tableName = base64_encode(authcode($project_info[0]['database_table_name'], "encode", $bookId . $projectId . $time)); //图片要插入的表的名字
        if (count($project_info) > 1) {
            return view('OtherPage/Error', [
                "errorCode" => 2006,
                "errorTitle" => "发生严重错误",
                "errorMsg" => "这一个漫画id对应多个漫画请尝试修复 这是不允许的操作",
            ]);
        }
        if (count($project_info) < 1) {
            return view('OtherPage/Error', [
                "errorCode" => 2007,
                "errorTitle" => "发生严重错误",
                "errorMsg" => "为检索到漫画信息",
            ]);
        }
        View::assign('useradmin', "useradmin");
        return view('Edit/EditProject/EditProject', [
            "projectTitle" => $project_info[0]['project_title'],
            "projectOrder" => $project_info[0]['order'],
            "useradmin" => config("useradminConfig.useradmin_serverHost"),
            "time" => $time,
            "hashHmac_bookId" => $hashHmac_bookId,
            "hashHmac_projectId" => $hashHmac_projectId,
            "bookId" => $bookId,
            "projectId" => $projectId,
            "image_sever" => config("globalsettings.image_sever"),
            "database_table_name" =>  $tableName,
        ]);
    }
}
